/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kotionokyurievna.gmail.com.circlebuffer.logic;

import java.util.Random;

/**
 *
 * @author Kateryna_Reznik
 */
public class Producer implements Runnable {
    private CircularBuffer cBuffer;
    private Random generator;

    public Producer(CircularBuffer cBuffer) {
        this.cBuffer = cBuffer;
        generator = new Random();
    }

    public void run() {
        
        while (true) {
            cBuffer.put(generator.nextInt(5));
            try {
                Thread.sleep(1);
            } 
            catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
